import { IFeidaoAiBrowserComponent } from '@dfeidao/atom-web/interfaces';
// import remove from '@dfeidao/atom-web/local/remove';

import get from '@dfeidao/atom-web/local/get';
// import set from '@dfeidao/atom-web/local/set';

import javadsd from '@dfeidao/atom-web/msg/javadsd';
import nodejs from '@dfeidao/atom-web/msg/nodejs';
import error from '@dfeidao/atom-web/msgbox/error';
import success from '@dfeidao/atom-web/msgbox/success';
import a002 from './a002';
// import { systemid } from 'src/atom/config';

export default async function a003(fd: IFeidaoAiBrowserComponent) {
	// 保存
	// if (get(fd, 'prevent')) {
	// 	return;
	// }
	// set(fd, 'prevent', 1);

	const tenantid = get(fd, 'tenantid');
	const tenant_level = fd.data.node.querySelector<HTMLSelectElement>('[data-feidao-name="levl"]').value;
	// debugger

	// const tenant_name = fd.data.node.querySelector<HTMLInputElement>('[data-feidao-name="name"]').value;
	// if (!tenant_name) {
	// 	error('租户名称不能为空!');
	// 	return;
	// }
	// const link_man = fd.data.node.querySelector<HTMLInputElement>('[data-feidao-name="user"]').value;
	// const phone = fd.data.node.querySelector<HTMLInputElement>('[data-feidao-name="phone"]').value;
	// const email = fd.data.node.querySelector<HTMLInputElement>('[data-feidao-name="email"]').value;


	const productid = get(fd, 'productid');

	const res = await nodejs('tenant-inf/zj-000004/s003', { productid, tenantid, tenant_level });

	const condition = {
		param: {
			tenantid,
			productid
		}
	};

	const dsd = await javadsd<{ code: number }>('12', '', 'tenantlevelchangetenantform', condition);


	if (res === 'success' && dsd.code === 1) {
		success('修改成功!');
		// remove(fd, 'prevent');
		await a002(fd);
	} else {
		error('修改失败!');
	}

}
